package com.app.couponsharelife.ui.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.widget.TextView
import com.app.couponsharelife.R
import com.app.couponsharelife.utils.AppUtils

/**
 * Created by guluwa on 2018/12/5.
 */
class CheckInSuccessDialog(context: Context, themeResId: Int, private val index: Int) : Dialog(context, themeResId) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.check_in_success_dialog)
        initView()
    }

    private fun initView() {
        findViewById<TextView>(R.id.tvCheckInSuccess).text = "+${index}券力值"
        window!!.setWindowAnimations(R.style.scale_in_alpha_out)
        setCanceledOnTouchOutside(true)

        //设置dialog没有边距
        window!!.decorView.setPadding(0, 0, 0, 0)
        val lp = window!!.attributes
        val width = AppUtils.getDisplayMetrics(context).widthPixels * 0.37
        val height = width * 0.935
        lp.width = width.toInt()
        lp.height = height.toInt()
        window!!.attributes = lp
    }
}